package com.cloudlinkscm.base.authcenter.domain;

import com.cloudlinkscm.base.authcenter.dao.UserRoleRelationDao;
import com.cloudlinkscm.base.authcenter.model.UserRoleRelation;

import java.util.Collection;

/**
 * @author : tac
 * @date : 28/07/2017
 */
public class AbstractUserRoleManager {

    private UserRoleRelationDao dao;

    public UserRoleRelationDao getDao() {
        return dao;
    }

    public AbstractUserRoleManager(UserRoleRelationDao dao) {
        this.dao = dao;
    }

    /**
     * 关联用户角色关系
     * </br>
     * 将删除所有当前用户已存在的关联关系，并重新添加
     */
    public int relate4User(String userId, Collection<String> roleIds) {
        //todo::
        return 0;
    }

    /**
     * 关联用户角色关系
     * </br>
     * 对于已关系该角色的用户将不再重复关联
     */
    public int relate4Role(String roleId, Collection<String> userIds) {
        //todo::
        return 0;
    }

    public int deleteByUserId(String userId) {
        UserRoleRelation o = new UserRoleRelation();
        o.setUserId(userId);
        return dao.delete(o);
    }

    public int deleteByRoleId(String roleId) {
        //todo::
        return 0;
    }

}
